import java.util.Scanner;
public class 遍历{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            
            int[] array = new int[5];
            for(int i = 0 ; i < array.length ; i++){
                System.out.println("请输入数组第" + (i + 1) + "个数");
                int a = sc.nextInt();
                array[i] = a;
            }
            printarr(array);
        }
    }
    public static void printarr(int[] arr){
        System.out.print("数组遍历为：");
        System.out.print("[");
        for(int i = 0 ; i < arr.length ; i++){
            if(i == arr.length - 1){
                System.out.print(arr[i]);
            }else{
                System.out.print(arr[i] + " ");
            }
        }
        System.out.println("]");
    }
}